<template>
    <div>
        <input type="text" class="todoAdd" @blur="addList" v-model.trim="inputText" />
    </div>
</template>

<script>
    export default {
        data(){
            return{
                inputText:''
            }
        },
        //告诉组件自定义事件名字
        emits:['setlist'],
        methods:{
            //添加
            addList() {
                if (this.inputText.length > 0) {
                    this.$emit('setlist',{
                        check: false,
                        value: this.inputText,
                        isEdit: false
                    })
                    this.inputText = ''
                }
            },
        }
    }
</script>

<style lang="scss" scoped>
    @import url("./index.scss");
    .content {
        width: 600px;
        min-height: 400px;
        border-radius: 20px;
        background: #fff;
        margin: 0 auto;
        padding: 20px;
        box-sizing: border-box;
    
        .todoAdd {
            width: 100%;
            height: 40px;
            font-size: 20px;
        }
    
        .todo-item {
            height: 40px;
            margin-top: 10px;
            font-size: 24px;
            display: flex;
            align-items: center;
            border-radius: 10px;
            transition: all 0.7s;
    
            .todo-text {
                width: 100%;
    
                .del {
                    text-decoration: line-through;
                }
            }
    
            .del-box {
                width: 20px;
                height: 20px;
                border-radius: 50%;
                text-align: center;
                line-height: 20px;
                font-size: 14px;
                color: #fff;
                background: rgba(0, 0, 0, .5);
                display: none;
                cursor: pointer;
            }
        }
    
        .todo-item:hover {
            background: rgba(0, 0, 0, 0.1);
    
            .del-box {
                display: block;
            }
        }
    }
</style>
